<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>体育与健康课程管理系统</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/public/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/public/css/main.css"/>
    <link href="${pageContext.request.contextPath}/public/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <script type="text/javascript" src="${pageContext.request.contextPath}/public/js/libs/modernizr.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/public/js/jquery-3.2.1.min.js"></script>
    <script src="${pageContext.request.contextPath}/public/js/layer/layer.js"></script>
    <script src="${pageContext.request.contextPath}/public/laydate/laydate.dev.js"></script>
</head>
<body>
<div class="container clearfix" style="width:100%">
    <!--/sidebar-->
    <div class="main-wrap">

        <div class="crumb-wrap">
            <div class="crumb-list" style="background:#fff; border:0px"><i class="icon-font"></i>修改体育知识考试安排</div>
        </div>
        <div class="result-wrap">
            <div class="result-content">
                <form  id="myform">
                    <table class="insert-tab" width="100%">
                        <tbody>   
                            <tr>
                                <th><i class="require-red">*</i>考试名称：</th>
                                <td>
                                <input name='peTestId' style="display:none" type="text" value="${data.peTestId }" />
                                    <input class="common-text required" id="title" name="peTestName" size="85" value="${data.peTestName } " style="width:300px;height:32px" type="text">
                                </td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>考试要求：</th>
                                <td><textarea name="peTestAsk" class="common-textarea" id="content"  style="width:300px" >${data.peTestAsk }</textarea></td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>考试地点：</th>
                                <td>
                                    <input class="common-text required" id="title" name="peTestPlace" size="85" value="${data.peTestPlace }" style="width:300px;height:32px" type="text">
                                </td>
                            </tr>

                            <tr>
                                <th><i class="require-red">*</i>开始时间：</th>
                                <td>
                            	<input class="common-text required" id="title" name="peTestStarTime" class="laydate-icon" onclick="laydate({istime: true, format: 'YYYY-MM-DD/hh:mm:ss'})" size="85" value=<fmt:formatDate value="${data.peTestStarTime}"  pattern="yyyy-MM-dd/HH:mm:ss"/> style="width:300px;height:32px" type="text">           
                                </td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>结束时间：</th>
                                <td>
                            	<input class="common-text required" id="title" name="peTestEndTime" class="laydate-icon" onclick="laydate({istime: true, format: 'YYYY-MM-DD/hh:mm:ss'})" size="85" value=<fmt:formatDate value="${data.peTestEndTime}" pattern="yyyy-MM-dd/HH:mm:ss"/> style="width:300px;height:32px" type="text">           
                                </td>
                            </tr>              
                            <tr>
                                <th><i class="require-red">*</i>考试人数上限：</th>
                                <td>
                                    <input class="common-text required" id="title" name="peTestUpperLimit" size="85" value="${data.peTestUpperLimit }" type="text" onkeyup="value=value.replace(/[^\d.]/g,'')" style="width:300px;height:32px">
                                </td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>考试人数下限：</th>
                                <td>
                            <input class="common-text required" id="title" name="peTestLowerLimit" size="85" value="${data.peTestLowerLimit }" style="width:300px;height:32px" type="text">           
                                </td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>预约开始时间：</th>
                                <td>
                                    <input class="common-text required" id="title" name="orderStartTime" class="laydate-icon" onclick="laydate({istime: true, format: 'YYYY-MM-DD/hh:mm:ss'})" size="85" value=<fmt:formatDate value="${data.orderStartTime}"  pattern="yyyy-MM-dd/HH:mm:ss"/> style="width:300px;height:32px" type="text">
                                </td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>预约结束时间：</th>
                                <td>
                                    <input class="common-text required" id="title" name="orderEndTime" class="laydate-icon" onclick="laydate({istime: true, format: 'YYYY-MM-DD/hh:mm:ss'})" size="85" value=<fmt:formatDate value="${data.orderEndTime}" pattern="yyyy-MM-dd/HH:mm:ss"/> style="width:300px;height:32px" type="text">
                                </td>
                            </tr>
                           <tr>
                                <th></th>
                                <td>
                                    <input class="btn btn-primary btn6 mr10" value="提交" type="button">
                                    <input class="btn btn6"  onclick="history.go(-1)" value="返回" type="button">
                                </td>
                            </tr>
                        </tbody></table>
                </form>
            </div>
        </div>

    </div>
    <!--/main-->
</div>
</body>
<script type="text/javascript">
    $('.mr10').click(function(){ 
    	var peTestId=$('input[name=peTestId]');
        var peTestName=$('input[name=peTestName]');
    	var peTestAsk=$('textarea[name=peTestAsk]');
    	var peTestPlace=$('input[name=peTestPlace]');
    	var peTestUpperLimit=$('input[name=peTestUpperLimit]');
    	var peTestStarTime=$('input[name=peTestStarTime]');
    	var peTestEndTime=$('input[name=peTestEndTime]');
    	var peTestLowerLimit=$('input[name=peTestLowerLimit]');
        var orderStartTime=$('input[name=orderStartTime]');
        var orderEndTime=$('input[name=orderEndTime]');
    	
        if(peTestName.val()=="")
        {
            layer.msg('考试名称不能为空', { offset: ['0px', '40%'], icon:7,time:2000});  
            peTestName.focus();
            return ;
        }
        if(peTestAsk.val()=="")
        {
            layer.msg('考试要求描述不能为空', { offset: ['0px', '40%'], icon:7,time:2000});  
            peTestAsk.focus();
            return ;
        }
        if(peTestPlace.val()=="")
        {
            layer.msg('考试地点不能为空', { offset: ['0px', '40%'], icon:7,time:2000});  
            peTestPlace.focus();
            return ;
        }

        if(peTestStarTime.val()=="")
        {
            layer.msg('开始时间不能为空', { offset: ['0px', '40%'], icon:7,time:2000});  
            peTestStarTime.focus();
            return ;
        }
        
        if(peTestEndTime.val()=="")
        {
            layer.msg('结束时间不能为空', { offset: ['0px', '40%'], icon:7,time:2000});  
            peTestEndTime.focus();
            return ;
        }
        
        if(peTestUpperLimit.val()=="")
        {
            layer.msg('考试人数上限不能为空', { offset: ['0px', '40%'], icon:7,time:2000});  
            peTestUpperLimit.focus();
            return ;
        }
        
        if(peTestLowerLimit.val()=="")
        {
            layer.msg('考试人数下限不能为空', { offset: ['0px', '40%'], icon:7,time:2000});  
            peTestLowerLimit.focus();
            return ;
        }
        if(orderStartTime.val()=="")
        {
            layer.msg('预约开始时间不能为空', { offset: ['0px', '40%'], icon:7,time:2000});
            orderStartTime.focus();
            return ;
        }

        if(orderEndTime.val()=="")
        {
            layer.msg('预约结束时间不能为空', { offset: ['0px', '40%'], icon:7,time:2000});
            orderEndTime.focus();
            return ;
        }
        
		var StartTime = peTestStarTime.val().replace("/"," ");
		var EndTime	= peTestEndTime.val().replace("/"," ");
        var orderStartTime = orderStartTime.val().replace("/"," ");
        var orderEndTime = orderEndTime.val().replace("/"," ");
		
		$.post("${pageContext.request.contextPath}/petest/updatefun.action",{peTestId:peTestId.val(),peTestName:peTestName.val(),peTestAsk:peTestAsk.val(),
			peTestPlace:peTestPlace.val(),peTestUpperLimit:peTestUpperLimit.val(),peTestStarTime:StartTime,peTestEndTime:EndTime,peTestLowerLimit:peTestLowerLimit.val(),orderStartTime:orderStartTime,orderEndTime:orderEndTime},function(returndata)
			{
	            if(returndata.code==1){
	                layer.msg(returndata.message, { offset: ['0px', '40%'], icon:6,time:1000},function(){
	                	window.location.href="${pageContext.request.contextPath}/petest/petest.action";
	                });
	              }
	            else
	            	layer.msg(returndata.message, { offset: ['0px', '40%'], icon:5,time:2000});
			});

    });
</script>
</html>